﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/POS.master" CodeFile="AddEditCompany.aspx.cs" Inherits="Admin_AddEditCompany" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <script type="text/javascript">
        function clientItemSelected(source, eventArgs) {
            var id_textbox = '<%=hdfCity.ClientID%>';
            document.getElementById(id_textbox).value = eventArgs.get_value();
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
    <asp:ScriptManager runat="server" ID="ScriptManager1">
        
    </asp:ScriptManager>
    <div class="container">
        <h3>Add / Update New Company</h3>
        <div class="form-horizontal" id="divCustomerWrapper">
            <div class="form-group">
                <label class="control-label col-sm-4" for="Name">Company Name :</label><asp:Label Text="" ID="abc" runat="server" />
                <div class="col-sm-6">
                    <asp:TextBox runat="server" ID="txtCompany" class="form-control" placeholder="Company Name" />
                    <asp:RequiredFieldValidator ErrorMessage="Enter Company Name" ControlToValidate="txtCompany" runat="server" ForeColor="Red" />
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-sm-4" for="Name">Address :</label>
                <div class="col-sm-6">
                    <asp:TextBox runat="server" ID="txtAddress" class="form-control" placeholder="Address" />
                    <asp:RequiredFieldValidator ErrorMessage="Enter Addresss" ControlToValidate="txtAddress" runat="server" ForeColor="Red" />
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-sm-4" for="Name">City :</label>
                <div class="col-sm-6">
                    <asp:TextBox runat="server" ID="txtCity" class="form-control" placeholder="City" />
                    <asp:RequiredFieldValidator ErrorMessage="Enter City" ControlToValidate="txtCity" runat="server" ForeColor="Red" />
                    <cc1:AutoCompleteExtender ID="cityAutoExtender" TargetControlID="txtCity"  ServiceMethod="SearchCities" OnClientItemSelected="clientItemSelected"
                        runat="server" MinimumPrefixLength="2" CompletionInterval="1000" EnableCaching="true" CompletionSetCount="10">
                    </cc1:AutoCompleteExtender>
                    <asp:HiddenField runat="server" ID="hdfCity" />
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-sm-4" for="Name">Phone :</label>
                <div class="col-sm-6">
                    <asp:TextBox runat="server" ID="txtPhone" TextMode="Phone" class="form-control" placeholder="Phone No" />
                    <asp:RequiredFieldValidator ErrorMessage="Enter Phone No." ControlToValidate="txtPhone" runat="server" ForeColor="Red" />

                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-4 col-sm-8">
                    <asp:Button runat="server" ID="btnSaveCompany" CssClass="btn btn-success" Text="Save" OnClick="btnSaveCompany_Click" />
                    <asp:Button runat="server" ID="btnClearForm" CssClass="btn btn-danger" Text="Clear Form" CausesValidation="false" OnClick="btnClearForm_Click" />
                </div>
            </div>
        </div>
        <asp:GridView runat="server" ID="GridViewCompanies" AutoGenerateColumns="false" CssClass="col-sm-10 grid" AllowPaging="true" PageSize="5" 
            AlternatingRowStyle-BackColor="#ccffff" >
            <Columns>
                <asp:TemplateField HeaderText="Sr.#">
                    <ItemTemplate>
                        <%#Container.DataItemIndex+1 %>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Company">
                    <ItemTemplate>
                        <asp:Label ID="lblcompany" Text='<%#Bind("CompanyName") %>' runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="City">
                    <ItemTemplate>
                        <asp:Label ID="lblCity" Text='<%#Bind("City_Name") %>' runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Phone">
                    <ItemTemplate>
                        <asp:Label ID="lblPhone" Text='<%#Bind("Phone") %>' runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Address">
                    <ItemTemplate>
                        <asp:Label ID="lblAddress" Text='<%#Bind("Address") %>' runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Edit">
                    <ItemTemplate>
                        <asp:LinkButton ID="lbtnEditCompany" CausesValidation="false" Text="Edit" CommandArgument='<%#Bind("CompanyID") %>' OnClick="lbtnEditCompany_Click" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
    </div>
</asp:Content>

